package com.dengdai.apputils.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dengdai.applibrary.adapter.BaseCommExpandableListAdapter;
import com.dengdai.apputils.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @说明 测试分组列表数据源
 * @作者 LY
 * @时间 16/5/24 10:35
 * @邮箱 2743569843@qq.com
 * @版权 Copyright(c) 2016 LY-版权所有
 * @备注
 */
public class TestExpandableListAdapter extends BaseCommExpandableListAdapter {

    public TestExpandableListAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        GroupViewHolder groupViewHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.common_text_group_item, null);
            groupViewHolder = new GroupViewHolder(convertView);
            convertView.setTag(groupViewHolder);
        } else {
            groupViewHolder = (GroupViewHolder) convertView.getTag();
        }
        groupViewHolder.tvName.setText("Group====>>" + (groupPosition + 1));
        return convertView;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        ChildViewHolder childViewHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.common_text_chind_item, null);
            childViewHolder = new ChildViewHolder(convertView);
            convertView.setTag(childViewHolder);
        } else {
            childViewHolder = (ChildViewHolder) convertView.getTag();
        }

        childViewHolder.tvName.setText("Child====>>" + (groupPosition + 1) + "   " + (childPosition + 1));
        return convertView;
    }

    static class GroupViewHolder {
        @Bind(R.id.tvName)
        TextView tvName;

        GroupViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }

    static class ChildViewHolder {
        @Bind(R.id.tvName)
        TextView tvName;

        ChildViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
